package com.kikyou.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kikyou.mapper.PositionMapper;
import com.kikyou.pojo.Admin;
import com.kikyou.pojo.Position;
import com.kikyou.pojo.RespBean;
import com.kikyou.service.IOplogService;
import com.kikyou.service.IPositionService;
import com.kikyou.utils.AdminUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @program: kikyouback
 * @author: 李玉龙
 * @create: 2022-03-08 10:51
 **/
@Service
public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position> implements IPositionService {
        @Autowired(required = false)
        PositionMapper positionMapper;
        @Autowired(required = false)
        IOplogService oplogServiceImpl;
    /**
     * @Description: 分页查询
     * @Param: * @param null 
     * @return: RespBean
     * @Author: 李玉龙
     * @Date: 11:41 2022/3/9 
     */
    @Override
    public RespBean getiPosition( int currentPage, int pageSize) {
        Page<Position> page= new Page(currentPage,pageSize);
        positionMapper.selectPage(page,null);
        if(page!=null){
            return RespBean.success("获取职位序列成功",page);
        }
        return RespBean.error("获取职位序列不成功");
    }
    /** 
    * @Description:  创建
    * @Param: * @param null 
    * @return:  RespBean
    * @Author: 李玉龙
    * @Date: 11:41 2022/3/9 
    */ 
    @Override
    public RespBean PostiPosition(Position position) {
            int cont = positionMapper.insert(position);
            if(cont!=0){
                oplogServiceImpl.insertMessage("创建职位序列成功");
                return RespBean.success("创建职位序列成功");
            }
            return RespBean.error("创建职位序列不成功");
        }
    /** 
    * @Description: 编辑 
    * @Param: * @param null 
    * @return:  RespBean
    * @Author: 李玉龙
    * @Date: 11:42 2022/3/9 
    */     
    @Override
    public RespBean PutPosition( Position position){
            int cont = positionMapper.updateById(position);
            if (cont!=0) {
                oplogServiceImpl.insertMessage("编辑职位序列成功");
                return RespBean.success("编辑职位序列成功");
            }
            return RespBean.error("编辑职位序列失败");
        }
}